home comics writing pictures archive about

HexDump.asm

Language: 8080 Assembly
Last Modified: 2022-11-12 4:27:45 PM UTC
File Size: 8973 bytes
http://www.penguinstew.ca/example/AltairHexDump/HexDump.asm
;HexDumpprogrampromptsforStartAddressandEndAddressthenoutputs
;thememorybetweenthosetwoaddressesinintelHEXformat
ORG173000Q
LXISP173000Q;173000:061000366Initstackpointer
MVIA003Q;173003:076003ClearInit2SIOport
OUT020Q;173005:323020
MVIA025Q;173007:076025
OUT020Q;173011:323020
LXIHStartPmt;173013:041015367DisplayStartPrompt
CALLPrintStrZ;173016:315173366
CALLReadHex16;173021:315222366ReadStartAddress
LXIHEndPmt;173024:041035367DisplayEndPrompt
CALLPrintStrZ;173027:315173366
XCHG;173032:353
CALLReadHex16;173033:315222366ReadEndAddress
INXD;173036:023Incrementtomakeinclusive
MAINLOOP:MOVAE;173037:173Calculateremaninglength
SUBL;173040:225
MOVCA;173041:117
MOVAD;173042:172
SBBH;173043:234
JNZSET16;173044:302065366Setlengthto16ifgreaterthan255
MOVAC;173047:171
CPI020Q;173050:376020Setlengthto16ifgreaterthan16
JNCSET16;173052:322065366
CPI000Q;173055:376000
JZFINISH;173057:312155366Fininishdumpiflengthis0
JMPSTART;173062:303067366
SET16:MVIC020Q;173065:016020
START:PUSHD;173067:325Storeendaddress
XCHG;173070:353Storecurrentaddress
LXIHNewLine;173071:041055367Printrecordbegining
CALLPrintStrZ;173074:315173366
XCHG;173077:353Restorecurrentaddress
MOVEC;173100:131Storelength
MOVAE;173101:173Printlengthbyte
CALLPrintHex8;173102:315337366
ADDH;173105:204Checksumaccumulation
MOVDA;173106:127
MOVAH;173107:174Printhighaddressbyte
CALLPrintHex8;173110:315337366
MOVAL;173113:175Printlowaddressbyte
CALLPrintHex8;173114:315337366
ADDD;173117:202Checksumaccumulation
MOVDA;173120:127
MVIA0;173121:076060PrintDataRecordType
CALLPrintChar;173123:315206366
CALLPrintChar;173126:315206366
DATALOOP:MOVAM;173131:176Loadmemorybyte
CALLPrintHex8;173132:315337366Printmemorybyte
ADDD;173135:202Checksumaccumulation
MOVAD;173136:127
INXH;173137:043Movetonextbyte
DCRE;173140:035Decrementlength
JNZDATALOOP;173141:302131366Loopifbytesremain
CMA;173144:057Printchecksumas2scomplement
INRA;173145:074
CALLPrintHex8;173146:315337366
POPD;173151:321Restoreendaddress
JMPMAINLOOP;173152:303037366
FINISH:LXIHEOFLine;173155:041377366Printendoffilerecord
CALLPrintStrZ;173160:315173366
CHK:IN020Q;173163:333020Ensurebufferisempty
ANI002Q;173165:346002
JZCHK;173167:312163366
HLT;173172:166Complete
;PrintsaNullterminatedstringfromHL
PrintStrZ:MOVAM;173173:176
CPI000Q;173174:376000
RZ;173176:310
CALLPrintChar;173177:315206366
INXH;173202:043
JMPPrintStrZ;173203:303173366
;PrintsacharacterinAusesBastempstorage
PrintChar:MOVBA;173206:107
CHECK:IN020Q;173207:333020
ANI002Q;173211:346002
JZCHECK;173213:312207366
MOVAB;173216:170
OUT021Q;173217:323021
RET;173221:311
;ReadtwobyteshighbyteisinDandlowbyteisinE
ReadHex16:CALLReadHex8;173222:315232366ReadHighorderbyte
MOVDE;173225:123StoreValue
CALLReadHex8;173226:315232366ReadLoworderbyte
RET;173231:311
;ReadabyteandputsitinE
ReadHex8:CALLReadHex4;173232:315250366
RLC;173235:007
RLC;173236:007
RLC;173237:007
RLC;173240:007
MOVEA;173241:007
CALLReadHex4;173242:315250366
ADDE;173245:203
MOVEA;173246:137
RET;173247:311
;ReadsanibbleandputsitinAusesCastempstorage
ReadHex4:IN020Q;173250:333020
RRC;173252:017
JNCReadHex4;173253:322250366
IN021Q;173256:333021
CPI0;173260:376060
JCReadHex4;173262:332250366
CPI:;173265:376072
JCNUM;173267:332323366
CPIA;173272:376101
JCReadHex4;173274:332250366
CPIG;173277:376107
JCUPPER;173301:332330366
CPIa;173304:376141
JCReadHex4;173306:332250366
CPIg;173311:376147
JNCReadHex4;173313:322250366
MVIC127Q;173316:016127
JMPPRINT;173320:303332366
NUM:MVIC0;173323:016060
JMPPRINT;173325:303332366
UPPER:MVIC067Q;173330:016067
PRINT:CALLPrintChar;173332:315306366
SUBC;173335:221
RET;173336:311
;PrintsthebyteinAusinghexdigitsusesCastempstorage
PrintHex8:MOVCA;173337:117Storevalue
RRC;173340:017Rotatehighnibbletolownibble
RRC;173341:017
RRC;173342:017
RRC;173343:017
CALLPrintHex4;173344:315355366Printhighnibble
MOVAC;173347:171Restorevalue
CALLPrintHex4;173350:315355366Printlownibble
MOVAC;173353:171Restorevalue
RET;173354:311
;PrintsthenibbleinAusinghexdigits
PrintHex4:ANIA017Q;173355:346017Clearhighnibble
CPI012Q;173357:376012Ifgreaterthan10
JNCLETTER;173361:322371366Itsaletterdigitelseitsanumberdigit
ADI0;173364:306060Determineoffsetfrom0character
JMPOUTPUT;173366:303373366
LETTER:ADI067Q;173371:306067DetermineoffsetfromAcharacter
OUTPUT:CALLPrintChar;173373:315206366
RET;173376:311
EOFLine:\r\n:00000001FF;173377:015012072060060060060060060060061106106000
StartPmt:StartAddress:;173415:123164141162164040101144144162145163163072040000
EndPmt:\r\nEndAddress:;173435:015012105156144040101144144162145163163072040000
NewLine:\r\n:;173455:015012072000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148